<template>
  <div class="login-box" >
    
    <div class="container-box">
      <div class="left-box">
        <p class="fr-title">金融理财产品推荐系统</p>
        <p class="wellcome">欢迎回来</p>
        <p class="detail">这是一个金融投资产品推荐系统，一款让更多人收益的金融投资平台</p>
        <el-button @click="register" class="reg-btn" round>没账号，去注册</el-button>
        <div class="circle"></div>
        <div class="fk"></div>
        <div class="jx"></div>
      </div>
      <div class="right-box">
        <p class="login-text">系统登录</p>
        <el-form class="myForm"  v-model="myForm" label-width="100px">
          <el-form-item label="用户名" style="margin: 50px 0">
            <el-input @keyup.enter.native="Login" v-model="myForm.username" placeholder="请输入用户名"></el-input>
          </el-form-item>
          <el-form-item label="密码">
            <el-input type="password" v-model="myForm.password" placeholder="请输入用户名"></el-input>
          </el-form-item>
          <el-form-item style="margin: 0 100px">
            <el-button   @click="Login" type="primary">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
axios.defaults.withCredentials = true
export default {
  name: "Login",
  data() {
    return {
      myForm: {
        username: 'viego',
        password: '370280545'
      },
      rules: [],
    }
  },
  methods: {
    Login() {
      this.openFullScreen2()
      axios.post('/FinancialRecommend/user/login', this.myForm)
        .then(response => {
          debugger
          let type =''
          if (response.data.code === 200){
            type = 'success'
            localStorage.setItem("UID", response.data.data.userId)
            localStorage.setItem("username", response.data.data.username)
            localStorage.setItem("assets", response.data.data.assets)
            localStorage.setItem("img", response.data.data.img)
            localStorage.setItem("user", response.data.data)
            this.$router.push('/index')
          }else{
            type = 'warning'
          }
          const h = this.$createElement;
          this.$notify({
            title: response.data.msg,
            type: type
          });
         
        })
    },
    openFullScreen2() {
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(255,255,255,0.72)'
      });
      // this.loadingVisible = true
      setTimeout(() => {
        loading.close();
        // this.loadingVisible = false
      }, 500);
      
    },
    register(){
      this.$router.push("/register")
    }
  }
}
</script>

<style lang="less" scoped>
.left-box {
  width: 400px;
  height: 100%;
  border-radius: 20px 0 0 20px;
  background-color: rgb(43, 193, 123);
}

.right-box {
  width: 600px;
  height: 100%;
  background-color: white;
  border-radius: 0 20px 20px 0;
  
}

.login-box {
  position: absolute;
  bottom: 0;
  width: 99%;
  height: 100%;
  box-sizing: border-box;
  background-color: #e8ebeb;
}

.container-box {
  position: absolute;
  top: 70px;
  left: 255px;
  width: 1000px;
  height: 600px;
  display: flex;
  border-radius: 20px;
  //box-shadow: 18px 8px 15px 0px rgba(0, 0, 0, 0.2);
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)
}

.fr-title {
  text-align: center;
  font-size: 30px;
  font-family: 新宋体;
  font-weight: 600;
  color: black;
  margin-top: 70px;
}

.login-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 400px;
  height: 170px;
  margin-left: -233px;
  margin-top: -150px;
  padding: 40px;
  border-radius: 15px;
  background-color: white;
}

.login-btn {
  text-align: center;
  margin: 0 140px;
}

.wellcome {
  text-align: center;
  font-family: 新宋体;
  font-size: 30px;
  font-weight: 600;
  color: black;
  margin-top: 100px;
}

.detail {
  text-align: center;
  font-size: 16px;
  font-family: 新宋体;
  margin: 50px 50px;
}

//注册按钮
.reg-btn {
  width: 150px;
  height: 50px;
  margin: 0 125px;
  font-family: 新宋体;
}

.circle {
  position: absolute;
  bottom: 0;
  width: 200px;
  height: 200px;
  border-radius: 0 200px 0 20px;
  background-color: rgb(45, 199, 127);
}

.fk {
  width: 50px;
  height: 50px;
  background-color: rgb(45, 199, 127);
  position: absolute;
  top: 110px;
  left: 300px;
  transform: rotate(60deg);
}

.myForm {
  margin: 100px 100px;
}

.login-text {
  text-align: center;
  font-size: 30px;
  font-family: 新宋体;
  font-weight: 600;
  color: black;
  margin: 100px 0;
}

.jx {
  width: 100px;
  height: 30px;
  background-color: rgb(45, 199, 127);
  position: absolute;
  top: 480px;
  left: 300px;
  transform: rotate(60deg);
}

p {
  user-select: none;
}
</style>
